package com.project.frba.bifront.client.view.charts;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.user.client.ui.Composite;
import com.gwtext.client.data.FieldDef;
import com.gwtext.client.data.IntegerFieldDef;
import com.gwtext.client.data.RecordDef;
import com.gwtext.client.data.Store;
import com.gwtext.client.data.StringFieldDef;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.form.ComboBox;
import com.gwtext.client.widgets.layout.FitLayout;

public class ChartSelector extends Composite{
	
	private enum Type {TORTA, BARRA, LINEAS};
	
	private Window mainWindow = new Window();
	private ComboBox cbTypes = new ComboBox();
	private Map<String, Panel> panels = new HashMap<String, Panel>();
	
	public ChartSelector(){
		mainWindow.setLayout(new FitLayout());
		mainWindow.setTitle("Seleccion de grafico");
		mainWindow.setWidth(400  + 20);
		mainWindow.setHeight(200);
		mainWindow.setResizable(false);
		loadTypes();
		loadActions();
		
	
		initWidget(mainWindow);
	}

	private void loadActions() {
		
		
	}

	private void loadTypes() {
		FieldDef[] fieldDefs = new FieldDef[]{
				new StringFieldDef("id"), 
				new StringFieldDef("name"),
				};
		RecordDef recordDef = new RecordDef(fieldDefs);
		Store store = new Store(recordDef);
		cbTypes.setStore(store);
		cbTypes.setEmptyText("Seleccione un grafico...");
		cbTypes.setDisplayField("name"); 
		cbTypes.setMode(ComboBox.LOCAL); 
		cbTypes.setTriggerAction(ComboBox.ALL); 
		for (Type type :Type.values()) {
			store.add(recordDef.createRecord(new Object[]{type.ordinal(), "Grafico de " + type.name()}));
		}
	}

	public void show() {
		mainWindow.show();
	}
}
